package com.ruoyi.lnb.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lnb.domain.Institutionusers;
import com.ruoyi.lnb.service.IInstitutionusersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机构账号管理Controller
 * 
 * @author ruoyi
 * @date 2022-04-05
 */
@RestController
@RequestMapping("/lnb/institutionusers")
public class InstitutionusersController extends BaseController
{
    @Autowired
    private IInstitutionusersService institutionusersService;

    /**
     * 查询机构账号管理列表
     */
    @PreAuthorize("@ss.hasPermi('lnb:institutionusers:list')")
    @GetMapping("/list")
    public TableDataInfo list(Institutionusers institutionusers)
    {
        startPage();
        List<Institutionusers> list = institutionusersService.selectInstitutionusersList(institutionusers);
        return getDataTable(list);
    }

    /**
     * 导出机构账号管理列表
     */
    @PreAuthorize("@ss.hasPermi('lnb:institutionusers:export')")
    @Log(title = "机构账号管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Institutionusers institutionusers)
    {
        List<Institutionusers> list = institutionusersService.selectInstitutionusersList(institutionusers);
        ExcelUtil<Institutionusers> util = new ExcelUtil<Institutionusers>(Institutionusers.class);
        util.exportExcel(response, list, "机构账号管理数据");
    }

    /**
     * 获取机构账号管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('lnb:institutionusers:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(institutionusersService.selectInstitutionusersById(id));
    }

    /**
     * 新增机构账号管理
     */
    @PreAuthorize("@ss.hasPermi('lnb:institutionusers:add')")
    @Log(title = "机构账号管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Institutionusers institutionusers)
    {
        return toAjax(institutionusersService.insertInstitutionusers(institutionusers));
    }

    /**
     * 修改机构账号管理
     */
    @PreAuthorize("@ss.hasPermi('lnb:institutionusers:edit')")
    @Log(title = "机构账号管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Institutionusers institutionusers)
    {
        return toAjax(institutionusersService.updateInstitutionusers(institutionusers));
    }

    /**
     * 删除机构账号管理
     */
    @PreAuthorize("@ss.hasPermi('lnb:institutionusers:remove')")
    @Log(title = "机构账号管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(institutionusersService.deleteInstitutionusersByIds(ids));
    }
}
